<template>
  <div class="per-student-wrapper">
    <div class="per-student-form-wrapper">
      <el-form class="per-student-form"
               :model="student" >
        <el-row :gutter="50">
          <el-col :span="8">
            <el-form-item label="姓名:">
              {{student.name}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="50">
          <el-col :span="8">
            <el-form-item label="账号:">
              {{username}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="50">
          <el-col :span="8">
            <el-form-item label="性别 : ">
              {{student.gender}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="50">
          <el-col :span="8">
            <el-form-item label="学号 : ">
              {{student.schoolID}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="50">
          <el-col :span="8">
            <el-form-item label="学院 : ">
              {{student.department.name}}
            </el-form-item>
          </el-col>

        </el-row>
        <el-row :gutter="50">
          <el-col :span="8">
            <el-form-item label="专业 : ">
              {{student.major.name}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="班级 : ">
              {{student.classesId}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="50">

        </el-row>
        <el-row :gutter="50">
          <el-col :span="8">
            <el-form-item label="联系电话 : ">
              {{student.phone}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="联系邮箱 : ">
              {{student.email}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="宿舍地址 : ">
              {{student.dormitory}}
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div class="per-student-form-avatar">
        <img class="per-student-form-avatar-img" :src="student.face" />
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: "PerStudent",
    data() {
      return {
        studentIdByUser: null,
        username: '',
        squareUrl: "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png",
        student: {
          name: '',
          gender: '',
          department: {
            name: ''
          },
          major: {
            name: ''
          },
          classes: {
            name: ''
          },
          phone: '',
          email: '',
          dormitory: '',
          schoolID: '',
          face: ''
        }
      }
    },
    mounted() {
      this.initStudentIdByUser()
      this.getStudentById()
    },
    methods: {
      //  根据学生id获取学生
      getStudentById() {
        this.getRequest('/perinformation/student/' + this.studentIdByUser).then(resp => {
          if (resp) {
            this.student = resp
            this.student.face = 'data:image/jpeg;base64,' + this.student.face
          }
        })
      },
      //  获取当前操作系统的学生的id
      initStudentIdByUser() {
        let user = JSON.parse(window.sessionStorage.getItem('user'))
        this.studentIdByUser = user.studentId
        this.username = user.username
      }
    }
  }
</script>

<style lang="less">

  .per-student-wrapper {
    width: 90%;
    margin-top: 20px;
    margin-left: 40px;

    .per-student-form-wrapper {
      margin-top: 20px;
      box-shadow: 0 2px 4px rgba(0, 0, 0, .20), 0 0 6px rgba(0, 0, 0, .08);
      border-radius: 4px;
      padding: 20px 60px;
      display: flex;
      justify-content: space-between;

      .per-student-form {

        .per-student-form-course-tag {
          margin-right: 10px;
        }
      }

      .per-student-form-avatar {
        margin-right: 30px;

        .per-student-form-avatar-img {
          width: 150px;
        }
      }
    }
  }

</style>